﻿using System;
using System.Collections.Generic;
using EzDesk.Core.Model;
namespace EzDesk.EzAppApi.Utility
{
    public interface IEzApiClient
    {
        #region [ Globle Info ]
        Organization GetOrganizationInfo();
        #endregion


        #region [ UserInfos ]

        UserProfile GetUserProfileById(Guid userId);
        SimpleUser GetSimpleUserById(Guid userId);
        IList<SimpleUser> GetSimpleUserInfos(string memberstring);
        IList<UserProfile> GetUserProfiles(string memberstring);
        Dept GetDeptById(Guid id);
        IList<Dept> GetAllDepts();
        void UpdateHeadIcon(Guid userId, byte[] iconData, string iconType);
        UserHeadImage GetHeadIcon(Guid userId);
        Guid? CreateNewUser(UserProfile newUserProfile, string newPassword);
        void UpdateUserProfile(UserProfile userProfile);
        void ChangePassword(Guid userId, string oldPassword, string newPassword);

        #endregion 

        #region [ Groups & Memberstrings ]

        IList<Group> GetAllSystemGroups();
        Group GetGroupByName(string groupName);
        Group GetSystemGroup(string sysGroupName);

        IList<SimpleUser> GetAllUsersByMemberString(string memberString);
        IDictionary<Guid, string> GetChildrenByMemberString(string memberString);

        Group GetGroupById(Guid groupId);
        IList<Group> GetGroups(string groupIdStrs);

        #endregion
        
        #region [ Feed相关 ] 

        Guid SendFeed(string templateName, string feedData, string memberString,
                        Guid? senderId = null, string ignoreUsers = null, bool isAvailable = true);

        void SetFeedIsAvailable(Guid feedId, string memberString, bool isAvailable);
        void SetFeedsIsAvailable(string feedIdStrs, string memberstring, bool isAvailable);

        void SetFeedIsRead(Guid feedId, string memberString, bool isRead);
        void SetFeedsIsRead(string feedIdStrs, string memberstring, bool isRead);

        void UpdateFeedData(Guid updateFeedId, string newFeedData);
        void UpdateFeedsData(string feedIdsStr, string updateDataStr);

        void SetFeedRecord(Guid identity, string templateName, string memberstring, Guid feedId, string ignoreUsers);
        string GetFeedRecord(Guid identity, string templateName, string userId);

        void UpdatePersonalFeedData(Guid feedId, string memberstring, string feedDataEx);
        void UpdatePersonalFeedType(Guid feedId, string memberstring, string feedTypeStr);
        void UpdateFeedRecipients(Guid feedId, string memberstring);
        #endregion

        #region [ Permission 相关 ]
        /// <summary>
        /// 用户是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        bool UserHasPermission(string permissionStr, Guid userId);


        /// <summary>
        /// 用户组是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户组Id</param>
        /// <returns></returns>
        bool GroupHasPermission(string permissionStr, Guid groupId);
        #endregion

    }
}
